package com.alibaba.algo.apiimpl.user;

import com.alibaba.algo.Application;
import com.alibaba.algo.cooperation.common.BaseResult;
import com.alibaba.algo.cooperation.usercomponent.vo.req.user.CreatePositionReqVo;
import com.alibaba.algo.cooperation.usercomponent.vo.req.user.SavePositionRequestForSyncVO;
import com.alibaba.algo.cooperation.usercomponent.vo.req.user.UpdatePositionRequestVO;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.util.Lists;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author : WangZhiPan
 * @date : 2021/10/12 9:35
 */
@SpringBootTest(classes = Application.class)
@RunWith(SpringRunner.class)
@Slf4j
public class PositionServiceImplTest {

    @Autowired
    SysPositionServiceImpl positionService;

    @Test
    public void testUpdate() {
        UpdatePositionRequestVO req = new UpdatePositionRequestVO();
        req.setId(117L);
        req.setDescription("202110121040测试修改");
        req.setIsPrimary(0L);
        req.setName("开发2");

        BaseResult resp = positionService.updatePosition(req);

        log.info("resp={}", JSON.toJSONString(resp));
    }


    @Test
    public void testAdd() {
        CreatePositionReqVo req = new CreatePositionReqVo();
        req.setDescription("10131126测试新增");
        req.setIsPrimary(1L);
        req.setName("开发1126");
        req.setOrgIdList(Lists.newArrayList(67L,68L,69L));

        BaseResult resp = positionService.addPosition(req);

        log.info("resp={}", JSON.toJSONString(resp));
    }

    @Test
    public void test1() {
        SavePositionRequestForSyncVO savePositionRequestForSyncVO = new SavePositionRequestForSyncVO();
        savePositionRequestForSyncVO.setPosCode("96");
        savePositionRequestForSyncVO.setPosName("测试更新");
        savePositionRequestForSyncVO.setOrgCode("afsfasdsasd");
        positionService.saveOrUpdatePositionForSync(savePositionRequestForSyncVO);
    }
}
